package Cotrol
{
	import Model.Constants;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IEventDispatcher;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	
	public class GameTickControl extends EventDispatcher
	{
		private static var instance:GameTickControl;
		
		public static const GAMETICK:String="gameTick";
		
		private var m_timer:Timer;
		
		public function GameTickControl(target:IEventDispatcher=null)
		{
			super(target);
		}
		public static function getInstance():GameTickControl
		{
			if(null==instance)
			{
				instance=new GameTickControl();
			}
			return instance;
		}
		public function timeStart():void
		{
			m_timer=new Timer(Constants.GAME_TICK);
			m_timer.addEventListener(TimerEvent.TIMER,onTick);
			m_timer.start();
		}
		private function onTick(evt:Event):void
		{
			dispatchEvent(new Event(GAMETICK));
		}
	}
}